from lxml import etree
import json
from selenium import webdriver
import csv
from time import sleep
import random
import os
from pathlib import Path
import pandas as pd

#打开并读取txt文件，返回一个str
def open_txt(path,encoding='ANSI'):
    file = open(path,"r",encoding=encoding)
    content = file.read()
    file.close()
    return content

def open_csv(path, names = None, encoding = 'utf-8'):
    if names != None: header = None
    else: header = 0
    data = pd.read_csv(path, header=header, names=names, encoding=encoding)
    return data

def open_excel(path, names = None, encoding = 'utf-8'):
    if names != None: header = None
    else: header = 0
    data = pd.read_excel(path, header=header, names=names, encoding=encoding)
    return data
